//rely on: jquery.js

//$(document).ready(function(){});
$(function() {
	//ajax-hook
	$(document).ajaxSuccess(function(event, xhr, options) {
		//console.log('>> ajax complete');
		//console.log(event,xhr,options);
		//readyState==4 && status==200
		var result = xhr.responseJSON;
		if (!result.success) {
			if (result.code == 444) { //与服务端约定
				alert('请先登陆！');
				window.top.location.href = '/login.html';
			} else {
				alert('后台处理异常！\n Code: ' + result.code + '\n Msg: ' + result.msg);
			}
		}
	});
	$(document).ajaxError(function(event, xhr, options, exc) {
		alert("请求出错! \n" + xhr.status + "\n" + xhr.statusText);
		//console.log(event,xhr,options,exc);
	});
	
	//sessionStorage检查
	if(!sessionStorage){
		alert('请使用较新的主流浏览器，以支持sessionStorage！');
		window.top.location.href = '/login.html';
	}
	if(!sessionStorage.getItem('manageLogin')){
		alert('请先登陆！');
		window.top.location.href = '/login.html';
	}
});
